<template>
    <div>
        <h1>这是子组件</h1>
        <el-form-item label="父组件的值">
            <el-alert :title="msg" />
        </el-form-item>
        <el-form-item label="子组件的值">
            <el-input v-model="msgFromChild" />
        </el-form-item>
        <hr>
        <el-button type="primary" @click="$emit('childClick','来自子组件的值')">来自子组件的点击</el-button>
        <el-button @click="sendMsg">发送Child页面的消息 </el-button>

    </div>
</template>

<script>
import { ref } from 'vue'
import bus from 'vue3-eventbus'
export default {
    name: "Event",
    props: {
        msg: String
    },
    
    setup() {
        const msgFromChild = ref("我是子组件的值")
        const sendMsg = function(){
            bus.emit('getMsg',msgFromChild.value)
        }
        return {
            msgFromChild,
            sendMsg
        }
    }
}
</script>